﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DataAccess;

namespace Project
{
    /// <summary>
    /// Interaction logic for PrintReportOfConclusion.xaml
    /// </summary>
    public partial class PrintReportOfConclusion : UserControl
    {
        private long ComplaintId;
        public PrintReportOfConclusion(long complaintId)
        {
            ComplaintId = complaintId;
            InitializeComponent();
            var comp = ComplaintDataAccess.GetComplaintById(ComplaintId);
            lblCaseNumber.Content = comp.Id;
            lblIncidentNature.Content = comp.IncidentNature;
            lblRegistrationDate.Content = comp.RegistrationDate.ToShortDateString();
            lblIncidentDate.Content = comp.IncidentDate.Value.ToShortDateString();
            lblIncidentPlace.Content = comp.IncidentPlace + " (Zona " + comp.IncidentZone + ")";
            foreach (var caseDeriv in comp.CaseDerivation)
            {
                if (chkDerivJudge.Content.ToString() == caseDeriv.Institution)
                    chkDerivJudge.IsChecked = true;
                if (chkDerivPublicMinistery.Content.ToString() == caseDeriv.Institution)
                    chkDerivPublicMinistery.IsChecked = true;
                if (chkDerivFELCC.Content.ToString() == caseDeriv.Institution)
                    chkDerivFELCC.IsChecked = true;
                if (chkDerivDefensory.Content.ToString() == caseDeriv.Institution)
                    chkDerivDefensory.IsChecked = true;
                if (chkDerivOther.Content.ToString() == caseDeriv.Institution)
                    chkDerivOther.IsChecked = true;
            }
            var complainant = PersonAndActorDataAccess.GetActorByTypeAndComplaintId("Denunciante", ComplaintId);
            lblComplainantName.Content = complainant.Person.Name + " " + complainant.Person.PaternalName + " " + complainant.Person.MaternalName;
            lblComplainantCi.Content = complainant.Person.CiPassport;
            var victim = PersonAndActorDataAccess.GetActorByTypeAndComplaintId("Victima", ComplaintId);
            lblVictimName.Content = victim.Person.Name + " " + victim.Person.PaternalName + " " + victim.Person.MaternalName;
            lblVictimCi.Content = victim.Person.CiPassport;
            var aggressor = PersonAndActorDataAccess.GetActorByTypeAndComplaintId("Agresor", ComplaintId);
            lblAggressorName.Content = aggressor.Person.Name + " " + aggressor.Person.PaternalName + " " + aggressor.Person.MaternalName;
            lblAggressorCi.Content = aggressor.Person.CiPassport;
            var employees = ComplaintDataAccess.GetAllEmployeeOfComplaintFromComp(ComplaintId);
            foreach (var employeeOfComplaint in employees)
            {
                if (employeeOfComplaint.Responsability == "Asignada")
                {
                    lblAsignedName.Content = employeeOfComplaint.Employee.Name + " " +
                                             employeeOfComplaint.Employee.PaternalName + " " +
                                             employeeOfComplaint.Employee.MaternalName;
                    lblAsignedCi.Content = employeeOfComplaint.CIEmployee;
                }

            }
        }
    }
}
